```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Java重载与重写解析 | 技术小馆</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background-color: #f8f9fa;
            color: #333;
            line-height: 1.6;
        }
        .hero {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        .code-block {
            background-color: #2d2d2d;
            border-radius: 8px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        }
        .feature-card {
            transition: all 0.3s ease;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
        }
        .feature-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 15px rgba(0, 0, 0, 0.1);
        }
        .divider {
            height: 1px;
            background: linear-gradient(90deg, transparent, rgba(0,0,0,0.1), transparent);
        }
        .comparison-table {
            border-collapse: separate;
            border-spacing: 0;
            border-radius: 8px;
            overflow: hidden;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
        }
        .comparison-table th, .comparison-table td {
            padding: 12px 16px;
            border-bottom: 1px solid #e2e8f0;
        }
        .comparison-table tr:last-child td {
            border-bottom: none;
        }
        .mermaid {
            background-color: white;
            border-radius: 8px;
            padding: 20px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
        }
        .btn {
            transition: all 0.3s ease;
        }
        .btn:hover {
            transform: translateY(-2px);
        }
    </style>
</head>
<body class="min-h-screen">
    <!-- Hero Section -->
    <section class="hero text-white py-20 px-4 md:px-0">
        <div class="container mx-auto max-w-5xl flex flex-col items-center text-center">
            <div class="w-20 h-20 bg-white bg-opacity-20 rounded-full flex items-center justify-center mb-6">
                <i class="fas fa-code text-3xl"></i>
            </div>
            <h1 class="text-4xl md:text-5xl font-bold mb-4 font-serif">深入理解Java方法重载与重写</h1>
            <p class="text-xl md:text-2xl opacity-90 max-w-3xl leading-relaxed mb-8">
                掌握面向对象编程中这两个关键概念的区别与联系，提升代码设计与实现能力
            </p>
            <div class="flex space-x-4">
                <a href="#overloading" class="btn bg-white text-indigo-700 px-6 py-3 rounded-full font-medium hover:bg-opacity-90">重载详解</a>
                <a href="#overriding" class="btn bg-transparent border-2 border-white px-6 py-3 rounded-full font-medium hover:bg-white hover:bg-opacity-20">重写详解</a>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <main class="container mx-auto max-w-5xl px-4 md:px-0 py-16">
        <!-- Introduction -->
        <section class="mb-20">
            <div class="bg-white rounded-xl shadow-md p-8 md:p-10">
                <h2 class="text-2xl md:text-3xl font-bold mb-6 text-gray-800 font-serif">方法重载与重写：概念辨析</h2>
                <p class="text-gray-700 mb-6 text-lg leading-relaxed">
                    在Java面向对象编程中，<strong class="text-indigo-600">重载(Overloading)</strong>和<strong class="text-purple-600">重写(Overriding)</strong>是两种重要的方法处理机制，它们虽然名称相似，但在使用场景和实现方式上有着本质的区别。
                </p>
                <div class="flex justify-center my-8">
                    <div class="mermaid w-full max-w-2xl">
                        graph TD
                            A[方法处理机制] --> B[重载 Overloading]
                            A --> C[重写 Overriding]
                            B --> D[同一类中]
                            B --> E[方法名相同]
                            B --> F[参数列表不同]
                            C --> G[继承关系中]
                            C --> H[方法名相同]
                            C --> I[参数列表相同]
                    </div>
                </div>
                <p class="text-gray-700 text-lg leading-relaxed">
                    理解这两种机制的区别对于编写清晰、可维护的面向对象代码至关重要。本文将深入探讨它们的定义、特点和使用场景，并通过代码示例展示如何正确应用。
                </p>
            </div>
        </section>

        <!-- Overloading Section -->
        <section id="overloading" class="mb-20">
            <div class="flex items-center mb-8">
                <div class="w-12 h-12 bg-indigo-100 rounded-full flex items-center justify-center mr-4">
                    <i class="fas fa-layer-group text-indigo-600 text-xl"></i>
                </div>
                <h2 class="text-3xl font-bold text-gray-800 font-serif">方法重载(Overloading)</h2>
            </div>

            <div class="grid md:grid-cols-3 gap-6 mb-12">
                <div class="feature-card bg-white p-6 rounded-xl">
                    <div class="text-indigo-600 text-2xl mb-3">
                        <i class="fas fa-signature"></i>
                    </div>
                    <h3 class="text-xl font-bold mb-2 text-gray-800">相同方法名</h3>
                    <p class="text-gray-600">重载的方法必须有完全相同的名称</p>
                </div>
                <div class="feature-card bg-white p-6 rounded-xl">
                    <div class="text-indigo-600 text-2xl mb-3">
                        <i class="fas fa-list-ol"></i>
                    </div>
                    <h3 class="text-xl font-bold mb-2 text-gray-800">不同参数列表</h3>
                    <p class="text-gray-600">参数类型、数量或顺序必须不同</p>
                </div>
                <div class="feature-card bg-white p-6 rounded-xl">
                    <div class="text-indigo-600 text-2xl mb-3">
                        <i class="fas fa-exchange-alt"></i>
                    </div>
                    <h3 class="text-xl font-bold mb-2 text-gray-800">返回值无关</h3>
                    <p class="text-gray-600">返回值类型不能作为重载依据</p>
                </div>
            </div>

            <div class="bg-white rounded-xl shadow-md overflow-hidden mb-8">
                <div class="p-6">
                    <h3 class="text-xl font-bold mb-4 text-gray-800">重载示例代码</h3>
                    <div class="code-block p-4 rounded-lg mb-4">
                        <pre class="text-gray-200 font-mono text-sm"><code>public class OverloadingDemo {
    // 重载方法1：两个整数相加
    public int add(int a, int b) {
        return a + b;
    }

    // 重载方法2：三个整数相加
    public int add(int a, int b, int c) {
        return a + b + c;
    }

    // 重载方法3：两个浮点数相加
    public double add(double a, double b) {
        return a + b;
    }
}</code></pre>
                    </div>
                    <div class="flex items-start bg-blue-50 p-4 rounded-lg border border-blue-100">
                        <div class="text-blue-500 mr-3 mt-1">
                            <i class="fas fa-info-circle"></i>
                        </div>
                        <p class="text-blue-800">
                            <strong>关键点：</strong> 虽然三个方法都名为"add"，但它们的参数列表不同（参数数量或类型不同），因此构成有效的重载。
                        </p>
                    </div>
                </div>
            </div>
        </section>

        <!-- Overriding Section -->
        <section id="overriding" class="mb-20">
            <div class="flex items-center mb-8">
                <div class="w-12 h-12 bg-purple-100 rounded-full flex items-center justify-center mr-4">
                    <i class="fas fa-retweet text-purple-600 text-xl"></i>
                </div>
                <h2 class="text-3xl font-bold text-gray-800 font-serif">方法重写(Overriding)</h2>
            </div>

            <div class="grid md:grid-cols-3 gap-6 mb-12">
                <div class="feature-card bg-white p-6 rounded-xl">
                    <div class="text-purple-600 text-2xl mb-3">
                        <i class="fas fa-project-diagram"></i>
                    </div>
                    <h3 class="text-xl font-bold mb-2 text-gray-800">继承关系</h3>
                    <p class="text-gray-600">发生在子类对父类方法的重新定义</p>
                </div>
                <div class="feature-card bg-white p-6 rounded-xl">
                    <div class="text-purple-600 text-2xl mb-3">
                        <i class="fas fa-clone"></i>
                    </div>
                    <h3 class="text-xl font-bold mb-2 text-gray-800">方法签名相同</h3>
                    <p class="text-gray-600">方法名和参数列表必须完全一致</p>
                </div>
                <div class="feature-card bg-white p-6 rounded-xl">
                    <div class="text-purple-600 text-2xl mb-3">
                        <i class="fas fa-lock-open"></i>
                    </div>
                    <h3 class="text-xl font-bold mb-2 text-gray-800">访问控制</h3>
                    <p class="text-gray-600">访问修饰符不能比父类更严格</p>
                </div>
            </div>

            <div class="bg-white rounded-xl shadow-md overflow-hidden mb-8">
                <div class="p-6">
                    <h3 class="text-xl font-bold mb-4 text-gray-800">重写示例代码</h3>
                    <div class="code-block p-4 rounded-lg mb-4">
                        <pre class="text-gray-200 font-mono text-sm"><code>class Parent {
    public void display() {
        System.out.println("父类的 display 方法");
    }
}

class Child extends Parent {
    @Override
    public void display() {
        System.out.println("子类的 display 方法");
    }
}</code></pre>
                    </div>
                    <div class="flex items-start bg-purple-50 p-4 rounded-lg border border-purple-100">
                        <div class="text-purple-500 mr-3 mt-1">
                            <i class="fas fa-info-circle"></i>
                        </div>
                        <p class="text-purple-800">
                            <strong>关键点：</strong> 子类Child重写了父类Parent的display方法，方法签名完全相同，但提供了不同的实现。使用@Override注解可以确保我们确实是重写了父类方法。
                        </p>
                    </div>
                </div>
            </div>
        </section>

        <!-- Comparison Section -->
        <section class="mb-20">
            <div class="flex items-center mb-8">
                <div class="w-12 h-12 bg-yellow-100 rounded-full flex items-center justify-center mr-4">
                    <i class="fas fa-balance-scale text-yellow-600 text-xl"></i>
                </div>
                <h2 class="text-3xl font-bold text-gray-800 font-serif">重载与重写对比</h2>
            </div>

            <div class="bg-white rounded-xl shadow-md overflow-hidden">
                <div class="p-6">
                    <h3 class="text-xl font-bold mb-6 text-gray-800">关键区别一览</h3>
                    <div class="overflow-x-auto">
                        <table class="comparison-table w-full bg-white">
                            <thead class="bg-gray-50">
                                <tr>
                                    <th class="text-left font-semibold text-gray-700">特性</th>
                                    <th class="text-left font-semibold text-indigo-600">重载(Overloading)</th>
                                    <th class="text-left font-semibold text-purple-600">重写(Overriding)</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr>
                                    <td class="text-gray-700 font-medium">发生位置</td>
                                    <td>同一类中</td>
                                    <td>继承关系中</td>
                                </tr>
                                <tr>
                                    <td class="text-gray-700 font-medium">方法名</td>
                                    <td>必须相同</td>
                                    <td>必须相同</td>
                                </tr>
                                <tr>
                                    <td class="text-gray-700 font-medium">参数列表</td>
                                    <td>必须不同</td>
                                    <td>必须相同</td>
                                </tr>
                                <tr>
                                    <td class="text-gray-700 font-medium">返回值</td>
                                    <td>可以不同</td>
                                    <td>必须相同或兼容</td>
                                </tr>
                                <tr>
                                    <td class="text-gray-700 font-medium">访问修饰符</td>
                                    <td>无限制</td>
                                    <td>不能比父类更严格</td>
                                </tr>
                                <tr>
                                    <td class="text-gray-700 font-medium">异常抛出</td>
                                    <td>无限制</td>
                                    <td>不能抛出比父类更宽泛的检查异常</td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </section>

        <!-- Common Pitfalls Section -->
        <section class="mb-20">
            <div class="flex items-center mb-8">
                <div class="w-12 h-12 bg-red-100 rounded-full flex items-center justify-center mr-4">
                    <i class="fas fa-exclamation-triangle text-red-600 text-xl"></i>
                </div>
                <h2 class="text-3xl font-bold text-gray-800 font-serif">常见误区与注意事项</h2>
            </div>

            <div class="bg-white rounded-xl shadow-md overflow-hidden">
                <div class="p-6">
                    <div class="mb-8">
                        <h3 class="text-xl font-bold mb-4 text-gray-800">仅靠返回值无法实现重载</h3>
                        <div class="code-block p-4 rounded-lg mb-4">
                            <pre class="text-gray-200 font-mono text-sm"><code>public class ErrorDemo {
    // 编译错误：返回值不同，但参数列表相同
    public int add(int a, int b) {
        return a + b;
    }

    public double add(int a, int b) {
        return a + b;
    }
}</code></pre>
                        </div>
                        <div class="flex items-start bg-red-50 p-4 rounded-lg border border-red-100">
                            <div class="text-red-500 mr-3 mt-1">
                                <i class="fas fa-exclamation-circle"></i>
                            </div>
                            <p class="text-red-800">
                                <strong>错误分析：</strong> 在Java中，方法重载是根据方法签名（方法名+参数列表）来区分的，返回值类型不包含在方法签名中。因此，仅靠返回值类型不同无法实现方法重载，这会导致编译错误。
                            </p>
                        </div>
                    </div>

                    <div class="divider my-8"></div>

                    <div>
                        <h3 class="text-xl font-bold mb-4 text-gray-800">重写与隐藏的区别</h3>
                        <div class="flex flex-col md:flex-row gap-6">
                            <div class="flex-1">
                                <h4 class="font-bold mb-2 text-purple-600">方法重写</h4>
                                <p class="text-gray-700 mb-4">适用于实例方法，运行时根据对象实际类型决定调用哪个方法</p>
                                <div class="code-block p-4 rounded-lg">
                                    <pre class="text-gray-200 font-mono text-sm"><code>Parent p = new Child();
p.display(); // 调用子类重写的方法</code></pre>
                                </div>
                            </div>
                            <div class="flex-1">
                                <h4 class="font-bold mb-2 text-gray-600">方法隐藏</h4>
                                <p class="text-gray-700 mb-4">适用于静态方法，编译时根据引用类型决定调用哪个方法</p>
                                <div class="code-block p-4 rounded-lg">
                                    <pre class="text-gray-200 font-mono text-sm"><code>Parent p = new Child();
p.staticMethod(); // 调用父类的静态方法</code></pre>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Summary Section -->
        <section class="mb-20">
            <div class="bg-gradient-to-r from-indigo-500 to-purple-600 rounded-xl shadow-md p-8 md:p-10 text-white">
                <h2 class="text-2xl md:text-3xl font-bold mb-6 font-serif">核心要点总结</h2>
                <ul class="space-y-4 text-lg">
                    <li class="flex items-start">
                        <span class="mr-3">✓</span>
                        <span>重载是在同一类中定义多个同名方法，参数列表必须不同；重写是在子类中重新定义父类已有的方法，方法签名必须相同</span>
                    </li>
                    <li class="flex items-start">
                        <span class="mr-3">✓</span>
                        <span>重载是编译时多态的表现，重写是运行时多态的表现</span>
                    </li>
                    <li class="flex items-start">
                        <span class="mr-3">✓</span>
                        <span>返回值类型不能作为重载的依据，但重写方法的返回值类型必须与被重写方法兼容</span>
                    </li>
                    <li class="flex items-start">
                        <span class="mr-3">✓</span>
                        <span>重写方法的访问修饰符不能比被重写方法更严格，可以更宽松</span>
                    </li>
                    <li class="flex items-start">
                        <span class="mr-3">✓</span>
                        <span>使用@Override注解可以帮助编译器检查是否正确重写了父类方法</span>
                    </li>
                </ul>
            </div>
        </section>
    </main>

    <!-- Footer -->
    <footer class="bg-gray-900 text-white py-12">
        <div class="container mx-auto max-w-5xl px-4 md:px-0 text-center">
            <h3 class="text-xl font-bold mb-4">技术小馆</h3>
            <p class="text-gray-400 mb-6">探索编程世界的奥秘，分享技术知识</p>
            <div class="flex justify-center space-x-6">
                <a href="http://www.yuque.com/jtostring" class="text-gray-300 hover:text-white transition-colors">
                    <i class="fas fa-book-open mr-2"></i>语雀主页
                </a>
            </div>
            <div class="mt-8 text-gray-500 text-sm">
                &copy; 2023 技术小馆. All rights reserved.
            </div>
        </div>
    </footer>

    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: true,
                htmlLabels: true,
                curve: 'basis'
            }
        });
    </script>
</body>
</html>
```